﻿Public Class frmOpcion2

    Public WithEvents cc As ConnectedClient


    Private client As System.Net.Sockets.TcpClient

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        client = New System.Net.Sockets.TcpClient(frmPanelPrincipal.txtServidor.Text, frmPanelPrincipal.txtPuerto.Text)
        cc = New ConnectedClient(client)
        cc.SendMessage("Action: Login" & vbCrLf & "UserName: " & frmPanelPrincipal.txtUsuario.Text & vbCrLf & "Secret: " & frmPanelPrincipal.txtClave.Text & vbCrLf & vbCrLf)
    End Sub

    Private Sub cc_dataReceived(ByVal sender As ConnectedClient, ByVal message As String) Handles cc.dataReceived
        Dim vCadena As String = message
        If Len(TextBox1.Text) > 3000 Then TextBox1.Text = ""
        TextBox1.Text = TextBox1.Text & vbCrLf & vCadena
        TextBox1.Select(TextBox1.Text.Length, 0)
        TextBox1.ScrollToCaret()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Close()
    End Sub
End Class